import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    // 重定向
    { path: '/', redirect: '/home/index' },
    {
      path: '/home',
      component: () => import('@/views/home/home.vue'),
      children: [
        { path: 'index', component: () => import('@/views/home/index.vue') },
        { path: 'cla', component: () => import('@/views/home/cla.vue') },
        { path: 'shopCar', component: () => import('@/views/home/shopCar.vue') },
        { path: 'my', component: () => import('@/views/home/my.vue') },
      ]
    },
    // 注册
    {
      path: '/register',
      component: () => import('@/views/register/index.vue')
    },
    // 登录
    {
      path: '/login',
      component: () => import('@/views/login/index.vue')
    },
    // 订单
    {
      path: '/order/:index',
      component: () => import('@/views/order/index.vue')
    },
    // 详情
    {
      path: '/detail/:goods_id',
      component: () => import('@/views/detail/index.vue')
    },
    // 物流
    {
      path: '/address',
      component: () => import('@/views/address/index.vue')
    },
  ],
})

export default router
